<?php
/**
* phpCan - http://idc.anavallasuiza.com/
*
* phpCan is released under the GNU Affero GPL version 3
*
* More information at license.txt
*/

namespace data\formats;

defined('ANS') or die();

class Float extends Formats implements iFormats {
	var $format = 'float';

	public function check ($value) {
		$this->error = array();

		return $this->validate($value);
	}

	public function valueDB (\data\Data $Data, $value, $language = '', $id = 0) {
		return array(
			'' => str_replace(',', '.', $value[''])
		);
	}

	public function valueForm ($value) {
		return array(
			'' => str_replace('.', ',', $value[''])
		);
	}

	public function settings ($settings) {
		$this->settings = $this->setSettings($settings, array(
			'' => array(
				'db_type' => 'float',

				'length_min' => '0',
				'length_max' => '8,2',
				'unsigned' => true,
				'default' => '0.00',
				'value_min' => '0.00',
				'value_max' => '99999999.99'
			)
		));

		return $this->settings;
	}
}
?>
